package com.xpand.guava;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;

/**
 * @Author: wei.wang
 * @Description:
 * @Date 2017/12/27 18:09
 * @Modified
 */
public class TableTest {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        Table<String, String, Integer> table = HashBasedTable.create();
        table.put("1", "A", 0x1A);
        table.put("1", "B", 0x1B);
        table.put("1", "C", 0x1C);
        table.put("2", "A", 0x2A);
        table.put("2", "B", 0x2B);
        table.put("2", "C", 0x2C);
        table.put("3", "A", 0x3A);
        table.put("3", "B", 0x3B);
        table.put("3", "C", 0x3C);
        table.put("4", "A", 0x4A);
        table.put("4", "B", 0x4B);
        table.put("4", "C", 0x4C);

        System.out.println(table);
        // 按列取数据
        System.out.println(table.column("A"));
        System.out.println(table.size());
        System.out.println(table.cellSet());
        System.out.println(table.columnKeySet());
        System.out.println(table.columnMap());
        System.out.println(table.rowMap());
        System.out.println(mapper.writeValueAsString(table));
    }
}
